package com.itheima.myreflect1;

import com.itheima.domain.Student;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test2 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
//        需求：定义一个Student类，用反射去创建一个Student对象，要求使用两种方式：
//1. 通过Class对象的方法创建。
//2. 通过Constructor对象的方法创建。
        Class aClass = Class.forName("com.itheima.domain.Student");
        Constructor constructor = aClass.getDeclaredConstructor();
        Student s = (Student) constructor.newInstance();

        Student ss = (Student) aClass.newInstance();
    }
}
